<?php
namespace app\api\controller\mytool;
use think\Db;
use think\facade\Env;
use think\Controller;
use app\api\controller\Base;
use app\api\controller\Pub;
use app\common\model\user\Setting As Settingmodel;
use app\common\model\power\Rolepower;

class Setting extends Base
{   
    /**
     * 获取基本配置
     * @return [type] [description]
     */
    public function getinfo(){
        Rolepower::powerguard(204012);
        $data['get_screen_show_car_list'] = self::get_screen_show_car_list();
        return myok($data);
    }

    /**
     * 获取大屏车辆显示设置 true开启  false关闭
     * @return [type] [description]
     */
    public static function get_screen_show_car_list(){
        $set = new Settingmodel();
        $data = $set->getSetting('screen_show_car_list');
        if(empty($data)||$data['Content']=='false'){
            return false;
        }
        return true;
    }

    /**
     * 设置大屏车辆显示开启或者关闭
     * @param  boolean $option [description]
     * @return [type]          [description]
     */
    public static function switch_screen_show_car_list($option = false){
        Rolepower::powerguard(204012);
        $set = new Settingmodel();
        $set->saveData(['title'=>'screen_show_car_list','content'=>$option]);
        return myok('设置成功');
    }

     /**
     * 大屏密码检测
     * @return [type] [description]
     */
    public static function login_screen_password($pwd){
        $set = new Settingmodel();
        $data = $set->getSetting('screen_password');
        if(empty($data)||$data['Content']!==$pwd){
            return false;
        }
        return true;
    }

    /**
     * 设置 大屏密码
     * @param  boolean $option [description]
     * @return [type]          [description]
     */
    public static function set_screen_pasword($pwd = 'schd888'){
        Rolepower::powerguard(204012);
        if(empty($pwd)){return myerr('密码不可为空');}
        $set = new Settingmodel();
        $set->saveData(['title'=>'screen_password','content'=>$pwd]);
        return myok('设置成功');
    }
}
